//
//  MBReleaseView.m
//  发布求租
//
//  Created by MB__Lee on 2018/6/7.
//  Copyright © 2018年 MB__Lee. All rights reserved.
//

#import "MBReleaseView.h"

@interface MBReleaseView()

@property (weak, nonatomic) IBOutlet UIButton *protocolBTN;

@property (weak, nonatomic) IBOutlet UIButton *rightBTN;

@property (weak, nonatomic) IBOutlet UIButton *releaseBTN;

@end
static NSString *MBReleaseView_Identi = @"MBReleaseView";

@implementation MBReleaseView
-(void)awakeFromNib{
    [super awakeFromNib];
    
    NSString *proString = @"我已阅读并同意《租客网发布求租协议》";
    NSMutableAttributedString *mutStr = [[NSMutableAttributedString alloc] initWithString:proString attributes:@{NSFontAttributeName:MBFont(13)}];
    [mutStr setAttributes:@{NSForegroundColorAttributeName:MBLineColor} range:NSMakeRange(0, 7)];
    [mutStr setAttributes:@{NSForegroundColorAttributeName:MB_mainSelectedColor} range:NSMakeRange(6, 11)];
    
}
+(instancetype)MBReleaseViewCreat{
    MBReleaseView *re  = [[NSBundle mainBundle] loadNibNamed:MBReleaseView_Identi owner:nil options:nil].lastObject;
    re.frame = CGRectMake(0, 0, SCREEN_WIDTH, 94);
    return  re;
}

//协议按钮事件
- (IBAction)protocolAction:(UIButton *)sender {
   // 跳转到协议页面
    if ([self.delegate respondsToSelector:@selector(MBReleaseViewShowProtocolVC:)]) {
        [self.delegate MBReleaseViewShowProtocolVC:self];
    }
    
    
}
// ✔️ 按钮事件
- (IBAction)rightAction:(UIButton *)sender {
    
    sender.selected = !sender.selected;
    if (sender.selected) {
        //选中状态是 没有同意协议
        [sender setImage:[UIImage imageNamed:@"xuanzhong"] forState:UIControlStateSelected];
    }else{
        // 未选中状态  同意协议
        [sender setImage:[UIImage imageNamed:@"weixuan"] forState:UIControlStateNormal];
    }
    
    
    
}

// 发布按钮事件
- (IBAction)releaseAction:(UIButton *)sender {
    //1.判断 协议按钮 是未选中状态
    if (_protocolBTN.selected) {
        //提醒 用户同意
        
        
        return;
    }
    
    if ([self.delegate respondsToSelector:@selector(MBReleaseViewMakeRelease:)]) {
        [self.delegate MBReleaseViewMakeRelease:self];
    }
    
}

@end
